package com.demo.webflux.mongo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@Service
public class ArticleService {

	@Autowired
	private ArticleReactiveMongoRepository articleRepository;

	public Flux<Article> save(Mono<Article> article){
		return articleRepository.saveAll(article);
	}

	public Mono<Article> findOne(String id){
		return articleRepository.findById(id);
	}

	public Flux<Article> findAll(){
		return articleRepository.findAll().log("findAll");
	}

	public Mono<Void> delete(String id){
		return articleRepository.deleteById(id).log("deleteOneArticle");
	}

}
